@php
    $year = @date("Y",time());
      //一年有多少天
      $days = ($year % 4 == 0 && $year % 100 != 0 || $year % 400 == 0) ? 366 : 365;
      //今年第一天的时间戳
      $first = strtotime("$year-01-01");
      //今年最后一天的时间戳
      $last = strtotime("+ $days days", $first);
      $start=date('Y-01-01 00:00:00',$first);//获取今年的第一天
        $end=date('Y-m-d H:i:s',$last); //
        $days=\App\OrderPay::select(DB::raw("MONTH(create_time) as month ,sum(total_money) as sum"))->whereBetween('create_time',[$start,$end])->where('pay_status',1)->where('closed','!=',true)->where('refund_status','!=',\App\OrderPay::REFUND_STATUS_APPLIED)->groupBy('month')->pluck('sum','month')->toArray();
         $dayList=[];
         $price=0;
        for ($i=1;$i<=12;$i++){
            if(isset($days[$i])){
                $dayList['day'][]=$i;
                $dayList['num'][]=$days[$i];
                $price+=$days[$i];
            }else{
                $dayList['day'][]=$i;
                $dayList['num'][]=0;
            }
        }

@endphp
<div id="main1" style="width: 600px;height:400px;"></div>


<script>
    $(function () {
        var myChart = echarts.init(document.getElementById('main1'));
        var option = {
            title: {
                text: '本年每月销售额(共计{{$price}}元)'

            },

            xAxis: {
                type: 'category',
                data: {{json_encode($dayList['day'])}},
                name: '月份',
            },
            yAxis: {
                name: '销售额(元)',
                type: 'value'
            },
            series: [{
                data: {!! json_encode($dayList['num']) !!},
                type: 'line',
            }]
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    });

</script>z